package com.jeespring.leetcode.array;

import com.alibaba.fastjson.JSON;

/**
 * @Title: MoveZero
 * @Description:
 * @Author 张朝阳
 * @Date 2020/12/20 17:12
 */
public class MoveZero2 {
    static int[] nums = {0,1,0,3,12};
    public static void main(String[] args) {
        int index = 0;
        for (int i = 0; i < nums.length ; i++) {
            if ( nums[i] != 0 ){
                nums[index] = nums[i];
                if ( i != index){
                    nums[i] = 0;
                }
                index++ ;
            }
        }
        System.out.println(JSON.toJSONString(nums));
    }
}
